home *** CD-ROM | disk | FTP | other *** search
PiXCL source | 1996-07-25 | 3.6 KB | 178 lines |
- Initialize:
- WinGetActive(Win$)
- UseCoordinates(PIXEL)
- UseBackGround(TRANSPARENT,192,192,192)
- DrawBackGround
- WaitInput(100) {let NT and 95 catch up}
- InfoMenu(REMOVE)
- SetMenu()
- WinLocate(Win$,250,10,620,240,Res)
- Title$ = "For and While Loops"
- WinTitle(Win$, Title$)
- {WinShow(Title$,NOTOPMOST,Res)}
- DirGet(SourceDir$)
-
-
- SetMenu("E&xit!",Leave,
- ENDPOPUP,
- "&FOR Loops",IGNORE,
- "&Programmed FOR",ProgramFor,
- "&Structured FOR",ConstructFor,
- ENDPOPUP,
- "&WHILE Loops",IGNORE,
- "&Programmed WHILE",ProgramWhile,
- "&Structured WHILE",ConstructWhile,
- ENDPOPUP,
- "For-&If-While",ForIfWhile,
- ENDPOPUP,
- "&Help",IGNORE,
- "&Concept",Concept,
- "&View Source",ViewSource,
- "&About",About,
- ENDPOPUP)
-
- Wait_for_Input:
- WaitInput()
-
-
- Leave:
- End
-
- Concept:
- MessageBox(OK,1,INFORMATION,
- "This sample program demonstrates the two
- available methods of programming FOR and
- WHILE loops, using firstly:
- Labels and 'Goto' statements;
- and secondly:
- Structured FOR and WHILE
- Keywords.
-
- Look in the sources to see the differences.",
- "Structured Program controls",Res)
- Goto Wait_for_Input
-
- ViewSource:
- PXLFile$ = SourceDir$ + "\forwhile.pxl"
- CmdLine$ = "NotePad " + PXLFile$
- Run(CmdLine$)
- Goto Wait_for_Input
-
-
- About:
- AboutUser("Structured Program Loops with PiXCL 4.0",
- "FOR - NEXT and WHILE - ENDWHILE structures in PiXCL",
- "Sample PiXCL 4.0 program showing variety of built in icons drawn in the client area, depending on the loop parameters")
- Goto Wait_for_Input
-
-
- ProgramFor:
- Count = 0
- DrawBackGround
- For_Loop:
- DrawIcon( 1,1,0,0,ICON01)
- DrawIcon(41,1,0,0,ICON02)
- DrawIcon(81,1,0,0,ICON03)
- Count++
- Break
- If Count <= 200 Then Goto For_Loop
- DrawText(10,50,"Programmed For Loop complete")
- Goto Wait_for_Input
-
-
- ConstructFor:
- DrawBackGround
- For Count = 0 To 100 By 2
- DrawIcon( 1,1,0,0,ICON01)
- DrawIcon(41,1,0,0,ICON02)
- {If Count > 40 Then DrawIcon( 1,1,64,64,ICON11) Break}
- DrawIcon(81,1,0,0,ICON03)
- Next
- DrawNumber(150,20,Count)
-
- LastCount = 100
- Increment = 2
- Zero = 0
- Counter = 0
- For Count = Zero To LastCount By Increment
- DrawIcon( 1,41,0,0,ICON04)
- DrawIcon(41,41,0,0,ICON05)
- {If Count > 40 Then DrawIcon( 1,41,64,64,ICON11) Break}
- DrawIcon(81,41,0,0,ICON06)
- Counter += Increment
- Next
- DrawNumber(150,50,Counter)
-
-
-
- DrawText(10,80,"Structured For Loop complete.")
- Goto Wait_for_Input
-
-
-
-
-
-
- ProgramWhile:
- Count = 0
- DrawBackGround
- While_Loop:
- If Count > 100 Then Goto While_End
- DrawIcon( 1,1,0,0,ICON04)
- DrawIcon(41,1,0,0,ICON05)
- DrawIcon(81,1,0,0,ICON06)
- Count++
- Goto While_Loop
- While_End:
- DrawText(10,50,"Programmed While Loop complete.")
- Goto Wait_for_Input
-
-
-
-
-
- ConstructWhile:
- Count = 0
- DrawBackGround
- While Count <= 100
- DrawIcon( 1,1,0,0,ICON04)
- DrawIcon(41,1,0,0,ICON05)
- DrawIcon(81,1,0,0,ICON06)
- If Count > 50 Then DrawIcon( 1,41,0,0,ICON11) Break
- Count++
- EndWhile
- DrawNumber(150,20,Count)
-
- Count$ = "A" Count = 0
- While Count$ = "A"
- DrawIcon( 1,41,0,0,ICON07)
- DrawIcon(41,41,0,0,ICON08)
- DrawIcon(81,41,0,0,ICON09)
- If Count > 50 Then Count$ = "B"
- Count++
- EndWhile
- DrawNumber(150,50,Count)
- DrawText(10,80,"Structured While Loop complete.")
-
- Goto Wait_for_Input
-
- ForIfWhile:
- DrawBackground
- For A = 0 To 10
- C = A
- While C < 10
- If A < 5
- DrawIcon(1,1,0,0,ICON01)
- Else
- DrawIcon(1,1,0,0,ICON10)
- Endif
- C++
- EndWhile
- Next
-
- Goto Wait_for_Input
-
-
-
-
-